<template>
        <el-dialog title="新增" v-model="editFormVisible" :close-on-click-modal="false">
            <el-form ref="form" :model="form" :rules="rules" label-width="110px">
                <el-form-item v-if="!homeEdit" label="登录名">
                    <el-input v-model="form.FCode"></el-input>
                </el-form-item>
                <el-form-item v-if="!homeEdit" label="密码">
                    <el-input type="password" v-model="form.FPassWord" placeholder="********"></el-input>
                </el-form-item>
                <el-form-item v-if="!homeEdit" label="用户名">
                    <el-input v-model="form.FName"></el-input>
                </el-form-item>
                <el-form-item v-if="!homeEdit" label="真实名字">
                    <el-input v-model="form.FRealName" placeholder="多个人请使用英文逗号,隔开"></el-input>
                </el-form-item>
                <el-form-item label="私人手机">
                    <el-input v-model="form.FPhone"></el-input>
                </el-form-item>
                <el-form-item label="办公电话">
                    <el-input v-model="form.FTelPhone"></el-input>
                </el-form-item>
                <el-form-item label="邮箱">
                    <el-input v-model="form.FEMail"></el-input>
                </el-form-item>
                <el-form-item label="备注">
                    <el-input type="textarea" v-model="form.FNote"></el-input>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click.native="editFormVisible = false">取 消</el-button>
                <el-button type="primary" @click="save" :loading="loading">保存</el-button>
            </div>
      </el-dialog>
</template>

<script>
    import util from '../../common/util'
    export default {
        props:{
            homeEdit:Boolean
        },
        data() {
            return {
                form: {},
                rules: {
                    FCode: [{required: true,message: '请输入登录名', trigger: 'blur'}]
                },
                loading:false,
                editFormVisible:false
            }
        },
        methods: {
            switchLoading(flag){
                this.loading = flag
            },
            _openEdit(record) {
                this.editFormVisible = true
                this.form = Object.assign({},record)
            },
            _openAdd() {
                this.editFormVisible = true
                this.form = {FID:0}
            },
            save:function () {
                util.post("server/system/User.ashx?cmd=SaveUser",this.form,this.switchLoading,result=> {
                    util.msgSuc("保存成功")
                    this.editFormVisible = false
                    this.$emit("onSaveSuc",this.form)
                })
            }
        },
        mounted() {

        }
    }
</script>
